package edu.fsu.cs.SHPE;

import java.net.ConnectException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

public class SessionActivity extends Activity {
	private static final String TAG = "SHPE.SessionActivity";
	
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.session);
		setTitle("Session Information");
		
		SessionContainer session = null;
		
		try {
			session = new SessionContainer(Conference.insertId(getString(R.string.getSession), getIntent().getLongExtra("id", -1)));
		} catch (ConnectException e) {
			Toast.makeText(this, "Unable to Connect to Server", Toast.LENGTH_SHORT).show();
			e.printStackTrace();
		}
		
		if(session == null){
			Log.i(TAG, "Unable to get speaker");
			finish();
		}
		
		Session tmpSession = session.get(0);
		TextView tmp;
		
		
		if(tmpSession.getTitle() != null){
			tmp = (TextView)findViewById(R.id.txtTitle);
			tmp.setText(tmpSession.getTitle());
		}
		
		if(tmpSession.getDescription() != null){
			tmp = (TextView)findViewById(R.id.txtDescription);
			tmp.setText(tmpSession.getDescription());
		}
		
		if(tmpSession.getStartTime() != null){
			tmp = (TextView)findViewById(R.id.txtDate);
			tmp.setText(tmpSession.getStartTime() + "-" + tmpSession.getEndTime());
		}
		
		if(tmpSession.getRoom() != null){
			tmp = (TextView)findViewById(R.id.txtRoom);
			tmp.setText(tmpSession.getRoom());
		}
		
		
	}
	

}
